SynchronizedDictionary

Ecng.Collections

Represents a thread-safe dictionary that provides synchronization for its operations.

実装: ISynchronizedCollection<KeyValuePair<T, T>>, ISynchronizedCollection, ISynchronizable, ICollection<KeyValuePair<T, T>>, IEnumerable<KeyValuePair<T, T>>, IEnumerable, IDictionary<T, T>

コンストラクター

SynchronizedDictionary
public SynchronizedDictionary()
synchronizedDictionary = SynchronizedDictionary()

Initializes a new instance of the SynchronizedDictionary class.

SynchronizedDictionary
protected SynchronizedDictionary(IDictionary<TKey, TValue> inner)
synchronizedDictionary = SynchronizedDictionary(inner)

Initializes a new instance of the SynchronizedDictionary class with the specified inner dictionary.

inner
The inner dictionary to wrap.
SynchronizedDictionary
public SynchronizedDictionary(int capacity, IEqualityComparer<TKey> comparer)
synchronizedDictionary = SynchronizedDictionary(capacity, comparer)

Initializes a new instance of the SynchronizedDictionary class with the specified initial capacity and equality comparer.

capacity
The initial number of elements that the dictionary can contain.
comparer
The equality comparer to use when comparing keys.
SynchronizedDictionary
public SynchronizedDictionary(IEqualityComparer<TKey> comparer)
synchronizedDictionary = SynchronizedDictionary(comparer)

Initializes a new instance of the SynchronizedDictionary class with the specified equality comparer.

comparer
The equality comparer to use when comparing keys.
SynchronizedDictionary
public SynchronizedDictionary(int capacity)
synchronizedDictionary = SynchronizedDictionary(capacity)

Initializes a new instance of the SynchronizedDictionary class with the specified initial capacity.

capacity
The initial number of elements that the dictionary can contain.

プロパティ

Count
public int Count { get; }
value = synchronizedDictionary.Count

Gets the number of key-value pairs contained in the dictionary.

IsReadOnly
public bool IsReadOnly { get; }
value = synchronizedDictionary.IsReadOnly

Gets a value indicating whether the dictionary is read-only.

Item
public virtual TValue Item { get; set; }
value = synchronizedDictionary.Item
synchronizedDictionary.Item = value

Gets or sets the value associated with the specified key.

key
The key of the value to get or set.

戻り値: The value associated with the specified key.

Keys
public ICollection<TKey> Keys { get; }
value = synchronizedDictionary.Keys

Gets a collection containing the keys in the dictionary.

SyncRoot
public Lock SyncRoot { get; }
value = synchronizedDictionary.SyncRoot

Gets the synchronization root object used to synchronize access to the dictionary.

Values
public ICollection<TValue> Values { get; }
value = synchronizedDictionary.Values

Gets a collection containing the values in the dictionary.

メソッド

Add
public virtual void Add(TKey key, TValue value)
synchronizedDictionary.Add(key, value)

Adds the specified key and value to the dictionary.

key
The key of the element to add.
value
The value of the element to add.
Add
public void Add(KeyValuePair<TKey, TValue> item)
synchronizedDictionary.Add(item)

Adds a key-value pair to the dictionary.

item
The key-value pair to add.
Clear
public virtual void Clear()
synchronizedDictionary.Clear()

Removes all keys and values from the dictionary.

Contains
public bool Contains(KeyValuePair<TKey, TValue> item)
result = synchronizedDictionary.Contains(item)

Determines whether the dictionary contains a specific key-value pair.

item
The key-value pair to locate in the dictionary.

戻り値: true if the dictionary contains the key-value pair; otherwise, false.

ContainsKey
public virtual bool ContainsKey(TKey key)
result = synchronizedDictionary.ContainsKey(key)

Determines whether the dictionary contains the specified key.

key
The key to locate in the dictionary.

戻り値: true if the dictionary contains an element with the specified key; otherwise, false.

CopyTo
public virtual void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
synchronizedDictionary.CopyTo(array, arrayIndex)

Copies the elements of the dictionary to an array, starting at a particular array index.

array
The one-dimensional array that is the destination of the elements copied from the dictionary.
arrayIndex
The zero-based index in at which copying begins.
EnterScope
public Scope EnterScope()
result = synchronizedDictionary.EnterScope()

Enters a synchronized scope for thread-safe operations on the collection.

戻り値: A Scope that represents the synchronized scope.

GetEnumerator
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
result = synchronizedDictionary.GetEnumerator()

Returns an enumerator that iterates through the dictionary.

戻り値: An enumerator that can be used to iterate through the dictionary.

Remove
public virtual bool Remove(TKey key)
result = synchronizedDictionary.Remove(key)

Removes the value with the specified key from the dictionary.

key
The key of the element to remove.

戻り値: true if the element is successfully found and removed; otherwise, false.

Remove
public bool Remove(KeyValuePair<TKey, TValue> item)
result = synchronizedDictionary.Remove(item)

Removes the first occurrence of a specific key-value pair from the dictionary.

item
The key-value pair to remove.

戻り値: true if the key-value pair was successfully removed; otherwise, false.

System#Collections#IEnumerable#GetEnumerator()

Returns an enumerator that iterates through the dictionary.

戻り値: An enumerator that can be used to iterate through the dictionary.

TryGetValue
public virtual bool TryGetValue(TKey key, TValue value)
result = synchronizedDictionary.TryGetValue(key, value)

Gets the value associated with the specified key.

key
The key of the value to get.
value
When this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value for the type of the parameter.

戻り値: true if the dictionary contains an element with the specified key; otherwise, false.